package cn.edu.scau.cmi.yejiancong.simplefactory;





import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.Label;

import javafx.scene.control.SplitMenuButton;
import javafx.scene.control.TextArea;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.Pane;
import javafx.scene.canvas.Canvas;

public class viewController {
	@FXML
	private  BorderPane paner;
	@FXML
	private  Label nameLaber;
	@FXML
	private  Label numberLaber;
	@FXML
	private  ChoiceBox insure;
	@FXML
	private  AnchorPane apane;
	@FXML
	private  Button showBut;
	@FXML
	private TextArea information;
	
	public void init() {
		man yjc=new man();
		insurance insurance=null;
		
		nameLaber.setText(yjc.getName());
		numberLaber.setText(yjc.getNumber().toString());
		
		Image image =new Image(getClass().getResourceAsStream("yjc.jpg"));
		ImageView imageView = new ImageView();
		
		imageView.setImage(image);
		imageView.setFitHeight(100);
		imageView.setFitWidth(100);
		paner.setCenter(imageView);
		insure.setItems(FXCollections.observableArrayList(
			    "bodyInjur", "carBroke", "peopleDamge","otherCase"));
		
	}

	public void show() {
		
		
		insure.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() {
			public void changed(ObservableValue ov,Number value,Number newval) {
				insurance inse=null;
				inse=insuranceFactory.insuranceType(newval.intValue());
				information.setText(inse.information());
			}
		});
		
	}
	

}
